//
//  JDClassification.m
//  quxiangtao
//
//  Created by HHuajiang on 2018/12/7.
//  Copyright © 2018 shanhaijin. All rights reserved.
//

#import "JDShoppingListModel.h"

@implementation JDShoppingListModel
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{@"skuId":@"id"};
}

- (void)setGoods_price:(NSString *)goods_price {
    _goods_price = [self reviseString:goods_price];
}

- (void)setGoods_pricey:(NSString *)goods_pricey {
    _goods_pricey = [self reviseString:goods_pricey];
}

- (NSString *)reviseString:(NSString *)str
{
    //直接传入精度丢失有问题的Double类型
    double conversionValue = [str doubleValue];
    NSString *doubleString = [NSString stringWithFormat:@"%lf", conversionValue];
    NSDecimalNumber *decNumber = [NSDecimalNumber decimalNumberWithString:doubleString];
    return [decNumber stringValue];
}

+ (void)jdShoppingGoodListWitPage:(NSInteger)page ClassID:(NSString *)classID successBlock:(HttpRequestSuccess)succcess failBlock:(HttpRequestFailed)fail {
    
    [QNetWorkRequest jdongShopingLisParameter:@{@"pageno":[NSString stringWithFormat:@"%ld",page], @"pagesize":@"10", @"sort_id":@"1",@"classid":classID,} Success:^(id response) {
        NSArray *dictArr = response[@"data"];
        NSMutableDictionary *d = [NSMutableDictionary dictionaryWithDictionary:response];
        if (dictArr.count > 0) {
            // 转模型数组
            NSArray *modelArr = [JDShoppingListModel mj_objectArrayWithKeyValuesArray:dictArr];
            [d removeObjectForKey:@"data"];
            [d setObject:modelArr forKey:@"data"];
        }
        if (succcess) {
            succcess(d);
        }
    } Failure:^(NSError *error) {
        
    }];
}
@end
